package org.jeecg.modules.waybill.doc;


import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.dromara.easyes.annotation.Distance;
import org.dromara.easyes.annotation.IndexField;
import org.dromara.easyes.annotation.IndexId;
import org.dromara.easyes.annotation.rely.FieldType;
import org.dromara.easyes.annotation.rely.IdType;
import org.jeecg.common.aspect.annotation.Dict;
import org.jeecg.modules.waybill.entity.WlhyWaybill;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.beans.BeanUtils;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

/**
 * @Description: 订单表
 * @Author: jeecg-boot
 * @Date: 2024-04-11
 * @Version: V1.0
 */
@Data
@TableName("wlhy_waybill")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "WlhyWaybillDoc", description = "订单表")
public class WlhyWaybillDoc implements Serializable {
    private static final long serialVersionUID = 1L;


    /**
     * 主键
     */
    @IndexId(type = IdType.CUSTOMIZE)
    private String id;
    /**
     * 创建人
     */

    @IndexField(fieldType = FieldType.KEYWORD)
    private String createBy;
    /**
     * 创建日期
     */

    @IndexField(fieldType = FieldType.DATE)
    private Date createTime;
    /**
     * 更新人
     */

    @IndexField(fieldType = FieldType.KEYWORD)
    private String updateBy;
    /**
     * 更新日期
     */

    @IndexField(fieldType = FieldType.DATE)
    private Date updateTime;
    /**
     * 所属部门
     */

    @IndexField(fieldType = FieldType.KEYWORD)
    private String sysOrgCode;
    /**
     * 创建人
     */

    @IndexField(fieldType = FieldType.KEYWORD)
    private String userId;
    /**
     * 运单号
     */

    @IndexField(fieldType = FieldType.KEYWORD_TEXT)
    private String waybillNo;
    /**
     * 提货时间
     */

    @IndexField(fieldType = FieldType.DATE)
    private Date deliveryTime;
    /**
     * 预计送达时间
     */
    @IndexField(fieldType = FieldType.DATE)
    private Date estArrivalTime;
    /**
     * 发货人姓名
     */
    @IndexField(fieldType = FieldType.KEYWORD_TEXT)
    private String shipperName;
    /**
     * 发货人电话
     */
    @IndexField(fieldType = FieldType.KEYWORD_TEXT)
    private String shipperPhone;
    /**
     * 发货人证件号
     */
    @IndexField(fieldType = FieldType.KEYWORD_TEXT)
    private String shipperIdNum;
    /**
     * 发货人地区编码
     */
    @IndexField(fieldType = FieldType.KEYWORD_TEXT)
    private String shipperAreaCode;
    /**
     * 发货人地区名称
     */
    @IndexField(fieldType = FieldType.KEYWORD_TEXT)
    private String shipperAreaName;
    /**
     * 发货人详细地址
     */

    @IndexField(fieldType = FieldType.KEYWORD_TEXT)
    private String shipperDetailAddr;
    /**
     * 发货方经纬度
     */
    @IndexField(fieldType = FieldType.GEO_POINT)
    private String shipperLnglat;
    /**
     * 收货方姓名
     */

    @IndexField(fieldType = FieldType.KEYWORD_TEXT)
    private String consignerName;
    /**
     * 收货方电话
     */
    @IndexField(fieldType = FieldType.KEYWORD_TEXT)
    private String consignerPhone;
    /**
     * 收件方证件号
     */
    @IndexField(fieldType = FieldType.KEYWORD_TEXT)
    private String consignerIdNum;
    /**
     * 收货方地区编码
     */
    @IndexField(fieldType = FieldType.KEYWORD_TEXT)
    private String consignerAreaCode;
    /**
     * 收货方地区名称
     */
    @IndexField(fieldType = FieldType.KEYWORD_TEXT)
    private String consignerAreaName;
    /**
     * 收货方详细地址
     */
    @IndexField(fieldType = FieldType.KEYWORD_TEXT)
    private String consignerDetailAddr;
    /**
     * 收货人经纬度
     */
    @IndexField(fieldType = FieldType.GEO_POINT)
    private String consignerLnglat;
    /**
     * 货物名称
     */
    @IndexField(fieldType = FieldType.KEYWORD_TEXT)
    private String cargoName;
    /**
     * 货物件数
     */
    @IndexField(fieldType = FieldType.INTEGER)
    private Integer cargoPieces;
    /**
     * 货物重量
     */
    @IndexField(fieldType = FieldType.DOUBLE)
    private BigDecimal cargoWeight;
    /**
     * 货物体积
     */
    @IndexField(fieldType = FieldType.DOUBLE)

    private BigDecimal cargoVolume;
    /**
     * 货物价值
     */
    @IndexField(fieldType = FieldType.DOUBLE)
    private BigDecimal cargoPrice;
    /**
     * 货物备注
     */

    private String cargoRemark;
    /**
     * 代收款
     */
    @IndexField(fieldType = FieldType.DOUBLE)
    private BigDecimal invoicingFee;
    /**
     * 代收款支付方式
     */
    @IndexField(fieldType = FieldType.KEYWORD_TEXT)
    private String invoicingPayMode;
    /**
     * 是否收取代收款
     */
    @IndexField(fieldType = FieldType.KEYWORD_TEXT)
    private Integer izInvoicingFee;
    /**
     * 代收款订单号
     */
    @IndexField(fieldType = FieldType.KEYWORD_TEXT)
    private String invoicingOrderNum;
    /**
     * 实际代收款支付方式
     */
    @IndexField(fieldType = FieldType.KEYWORD_TEXT)
    private String invoicingRealPayMode;
    /**
     * 司机运费
     */
    @IndexField(fieldType = FieldType.DOUBLE)
    private BigDecimal driverFreightFee;
    /**
     * 结算运费状态
     */
    @IndexField(fieldType = FieldType.KEYWORD_TEXT)
    private Integer settleFreightStatus;
    /**
     * 运费结算时间
     */
    @IndexField(fieldType = FieldType.DATE)
    private Date settleFreightTime;
    /**
     * 运费结算方式
     */
    @IndexField(fieldType = FieldType.KEYWORD_TEXT)
    private String settleFreightMode;
    /**
     * 是否指派司机
     */
    @IndexField(fieldType = FieldType.KEYWORD_TEXT)
    private Integer izAssignDriver;
    /**
     * 接单时间
     */
    @IndexField(fieldType = FieldType.DATE)
    private Date orderTime;
    /**
     * 接单用户
     */
    @IndexField(fieldType = FieldType.KEYWORD_TEXT)
    private String driverUserId;
    /**
     * 司机车牌号
     */
    @IndexField(fieldType = FieldType.KEYWORD_TEXT)
    private String driverVehicleNo;
    /**
     * 司机电话
     */
    @IndexField(fieldType = FieldType.KEYWORD_TEXT)
    private String driverPhone;
    /**
     * 司机姓名
     */
    @IndexField(fieldType = FieldType.KEYWORD_TEXT)
    private String driverName;
    /**
     * 司机银行卡
     */
    @IndexField(fieldType = FieldType.KEYWORD_TEXT)
    private String driverBankId;
    /**
     * 司机银行开户名
     */
    @IndexField(fieldType = FieldType.KEYWORD_TEXT)
    private String driverBankHolder;
    /**
     * 司机银行卡号
     */
    @IndexField(fieldType = FieldType.KEYWORD_TEXT)
    private String driverBankCardNo;
    /**
     * 司机开户银行
     */
    @IndexField(fieldType = FieldType.KEYWORD_TEXT)
    private String driverBankName;
    /**
     * 浏览量
     */
    @IndexField(fieldType = FieldType.INTEGER)
    private Integer scanNum;
    /**
     * 评论量
     */
    @IndexField(fieldType = FieldType.INTEGER)
    private Integer commentNum;
    /**
     * 订单状态
     */
    @IndexField(fieldType = FieldType.KEYWORD_TEXT)
    private String waybillStatus;
    /**
     * 状态
     */
    @IndexField(fieldType = FieldType.KEYWORD_TEXT)
    private String status;


    @IndexField(fieldType = FieldType.KEYWORD_TEXT)
    private String companyName;

    @IndexField(fieldType = FieldType.KEYWORD_TEXT)
    private String companyLogo;

    @IndexField(fieldType = FieldType.KEYWORD_TEXT)
    private String companyId;

    @Distance(decimalPlaces=4)
    @IndexField(exist = false)
    private Double distanceKm;


    public WlhyWaybillDoc(WlhyWaybill wlhyWaybill){
        BeanUtils.copyProperties(wlhyWaybill, this);
        String[] shipperLocal = wlhyWaybill.getShipperLnglat().split(",");
        this.setShipperLnglat(String.format("%s,%s", shipperLocal[1], shipperLocal[0]));
        String[] consignerLocal = wlhyWaybill.getConsignerLnglat().split(",");
        this.setConsignerLnglat(String.format("%s,%s", consignerLocal[1], consignerLocal[0]));
    }
}
